﻿@{
    Layout = null; 
}
@using System.Web.Mvc.Html
@using Nop.Plugin.Misc.MailChimp.Models
@using Nop.Web.Framework
@model MailChimpSettingsModel
<div>
    @using (Html.BeginForm())
    {
        <script type="text/javascript">
            $(document).ready(function () {

                $("#@Html.FieldIdFor(model => model.AutoSync)").click(toggleAutoSync);

                toggleAutoSync();
            });

            function toggleAutoSync() {
                if (getE('@Html.FieldIdFor(model => model.AutoSync)').checked) {
                    $('#pnlAutoSyncEachMinutes').show();
                }
                else {
                    $('#pnlAutoSyncEachMinutes').hide();
                }
            }

        </script>
    
        <table class="adminContent">
            <tr>
                <td class="adminTitle">
                    @Html.LabelFor(m => m.ApiKey):
                </td>
                <td class="adminData">
                    @Html.EditorFor(m => m.ApiKey)
                    @Html.ValidationMessageFor(m => m.ApiKey)
                </td>
            </tr>
            <tr>
                <td class="adminTitle">
                    @Html.LabelFor(m => m.WebHookKey):
                </td>
                <td class="adminData">
                    @Html.EditorFor(m => m.WebHookKey)
                    @Html.ValidationMessageFor(m => m.WebHookKey)
                </td>
            </tr>
            <tr>
                <td class="adminTitle">
                    @Html.LabelFor(m => m.DefaultListId):
                </td>
                <td class="adminData">
                    @Html.DropDownListFor(m => m.DefaultListId, Model.ListOptions)
                    @Html.ValidationMessageFor(m => m.DefaultListId)
                </td>
            </tr>
            <tr>
                <td class="adminTitle">
                    @Html.LabelFor(m => m.AutoSync):
                </td>
                <td class="adminData">
                    @Html.EditorFor(m => m.AutoSync)
                    @Html.ValidationMessageFor(m => m.AutoSync)
                </td>
            </tr>
            <tr id="pnlAutoSyncEachMinutes">
                <td class="adminTitle">
                    @Html.LabelFor(model => model.AutoSyncEachMinutes):
                </td>
                <td class="adminData">
                    @Html.EditorFor(model => model.AutoSyncEachMinutes)
                    @Html.ValidationMessageFor(model => model.AutoSyncEachMinutes)
                </td>
            </tr>
            @if (!String.IsNullOrEmpty(Model.SaveResult))
            {
                <tr>
                    <td colspan="2" width="100%" style="color: red">
                        @Model.SaveResult
                    </td>
                </tr>
            }
            <tr>
                <td colspan="2" width="100%">
                    <button type="submit" name="save" value="save" class="t-button">
                        @T("Admin.Common.Save")</button>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="left">
                    <hr />
                    <b>@T("Plugin.Misc.MailChimp.ManualSync.Hint")</b>
                </td>
            </tr>
            @if (!String.IsNullOrEmpty(Model.SyncResult))
            {
                <tr>
                    <td colspan="2" width="100%" style="color: red">
                        @Html.Raw(Model.SyncResult)
                    </td>
                </tr>
            }
            <tr>
                <td colspan="2" width="100%">
                    <button type="submit" name="sync" value="sync" class="t-button">
                        @T("Plugin.Misc.MailChimp.ManualSync")</button>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="left">
                    <hr />
                    <b>@T("Plugin.Misc.MailChimp.QueueAll.Hint")</b>
                </td>
            </tr>
            <tr>
                <td colspan="2" width="100%">
                    <button type="submit" name="queueall" value="queueall" class="t-button">
                        @T("Plugin.Misc.MailChimp.QueueAll")</button>
                </td>
            </tr>
        </table>
    }
</div>
